﻿using System.Collections;
using System.Collections.Generic;
using INTEX.DataBase.Tools;
using ReflectionStudio.Core;
using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.IO;
using WPFExcelReport.Helpers;
namespace WPFExcelReport
{
   
    public partial class ITXEXRPT
    {
        public string YCAPrint(ref bool IsReturn)
        {
            if (app.company != "YCA")
                return filename;
            Helper.GetDate(ref date, ref year, ref month, ref day);
            switch (DocType)
            {

                #region====YCA==============
                case "YCAFSAV95"://生产进度
                    destfolder = SetFolder(Root, "生产进度");
                    #region====文件命名==============
                    order = date;
                    DestFile = destfolder + "\\生产进度" + order + ".xls";
                    #endregion
                    #region=====空白文档=======
                    Standard = "YCAFSAV95";
                    exAgent.CreateNewSheet(temp + ".xls", Standard);
                    tempfile = exAgent.FileName;
                    #endregion
                    YCAFSAV95(dsSource);
                    //   strExcelFile = @"YCA\YCAFSAV95.xls";
                    break;

                case "YCACOFS"://生产进度
                    destfolder = SetFolder(Root, "成本");
                    #region====文件命名==============
                    if (!dsSource.Tables.Contains("ICC_ABPOS_MCO"))
                    {
                        IsReturn = true;
                    }


                    dwOrder = dsSource.Tables["ICC_ABPOS_MCO"].Rows[0];
                    if (dwOrder == null)
                    {
                        IsReturn = true;
                    }
                    KRS = dwOrder["KRS"].ToString().Trim();
                    LFD = dwOrder["LFD"].ToString().Trim();
                    order = KRS + "_" + Helper.GetSubRollNum(LFD) + "_" + dwOrder["ART"].ToString().Trim();
                    DestFile = destfolder + "\\成本" + order + ".xls";
                    #endregion
                    #region=====空白文档=======
                    Standard = "YCACOFS";
                    exAgent.CreateNewSheet(temp + ".xls", Standard);
                    tempfile = exAgent.FileName;
                    #endregion
                    YCACOFS(dsSource);
                    //   strExcelFile = @"YCA\YCAFSAV95.xls";
                    break;
                #endregion



                case "YCAEK03DOC"://采购单 
                    #region======YCAEK03DOC==============
                    destfolder = SetFolder(Root, "采购单");
                    #region====文件命名==============
                    order = GetYCAEKOrd(dsSource, DocType);
                    DestFile = destfolder + "\\采购单" + order + ".xls";
                    #endregion
                    #region=====空白文档=======
                    Standard = "YCAEK03DOC";
                    exAgent.CreateNewSheet(temp + ".xls", Standard);
                    tempfile = exAgent.FileName;
                    #endregion
                    YCAEK03DOC(dsSource);
                    break;
                #endregion
                case "YCAEK03EXT"://采购单 
                    #region======YCAEK03EXT==============
                    destfolder = SetFolder(Root, "采购单");
                    #region====文件命名==============
                    order = GetYCAEKOrd(dsSource, DocType);
                    DestFile = destfolder + "\\采购单" + order + ".xls";
                    #endregion
                    #region=====空白文档=======
                    Standard = "YCAEK03EX";
                    exAgent.CreateNewSheet(temp + ".xls", Standard);
                    tempfile = exAgent.FileName;
                    #endregion
                    YCAEK03EXT(dsSource);
                    break;
                #endregion
                case "YCAEK03FP"://采购单 
                    #region======YCAEK03FP==============
                    destfolder = SetFolder(Root, "采购单");
                    #region====文件命名==============
                    order = GetYCAEKOrd(dsSource, DocType);
                    DestFile = destfolder + "\\采购单" + order + ".xls";
                    #endregion
                    #region=====空白文档=======
                    Standard = "YCAEK03FP";
                    exAgent.CreateNewSheet(temp + ".xls", Standard);
                    tempfile = exAgent.FileName;
                    #endregion
                    YCAEK03FP(dsSource);
                    break;
                #endregion

                case "YCAEK03PO"://采购单 
                    #region======YCAEK03PO==============
                    destfolder = SetFolder(Root, "采购单");
                    #region====文件命名==============
                    order = GetYCAEKOrd(dsSource, DocType);
                    DestFile = destfolder + "\\采购单" + order + ".xls";
                    #endregion
                    #region=====空白文档=======
                    Standard = "YCAEK03PO";
                    exAgent.CreateNewSheet(temp + ".xls", Standard);
                    tempfile = exAgent.FileName;
                    #endregion
                    YCAEK03PO(dsSource);
                    break;
                #endregion

                case "YCAEKSEND"://采购单
                    #region======YCAEKSEND==============
                    destfolder = SetFolder(Root, "发料单");
                    #region====文件命名==============
                    order = GetYCAEKOrd(dsSource, DocType);
                    DestFile = destfolder + "\\发料单" + order + ".xls";
                    #endregion
                    #region=====空白文档=======
                    Standard = "YCAEKSEND";
                    exAgent.CreateNewSheet(temp + ".xls", Standard);
                    tempfile = exAgent.FileName;
                    #endregion
                    YCAEKSEND(dsSource);
                    break;
                #endregion

                case "YCAEKPAID"://订单列表
                    #region======YCAEKPAID==============
                    destfolder = SetFolder(Root, "付款列表");
                    #region====文件命名==============
                    order = date;
                    DestFile = destfolder + "\\付款列表" + order + ".xls";
                    #endregion
                    #region=====空白文档=======
                    Standard = "YCAEKPAID";
                    exAgent.CreateNewSheet(temp + ".xls", Standard);
                    tempfile = exAgent.FileName;
                    #endregion
                    YCAEKPAID(dsSource);
                    break;
                #endregion

                case "YCAEK02LIST"://采购统计
                    destfolder = SetFolder(Root, "采购统计");
                    #region====文件命名==============
                    order = date;
                    DestFile = destfolder + "\\采购统计" + order + ".xls";
                    #endregion
                    #region=====空白文档=======
                    Standard = "YCAEK02LIST";
                    exAgent.CreateNewSheet(temp + ".xls", Standard);
                    tempfile = exAgent.FileName;
                    #endregion
                    YCAEK02LIST(dsSource);
                    break;
                case "YCAEKAB15"://采购统计
                    destfolder = SetFolder(Root, "采购统计");
                    #region====文件命名==============
                    order = date;
                    DestFile = destfolder + "\\采购统计" + order + ".xls";
                    #endregion
                    #region=====空白文档=======
                    Standard = "YCAEKAB15";
                    exAgent.CreateNewSheet(temp + ".xls", Standard);
                    tempfile = exAgent.FileName;
                    #endregion
                    YCAEKAB15(dsSource);
                    break;
            }
            return filename;
        }

    }
}
